import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.print.PageFormat;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;

/**
 * Gui portion of the program Uses DrawFace.java, DrawGnomon.java,
 * SundialMath.java
 * 
 * @author Arun Lee, Michael Terada, Marek Lopez
 */
public class ics314ui extends javax.swing.JApplet {

	private double lat;
	private double lon;
	DrawGnomon drawG;
	DrawFace drawF;
	private String address;
	private String city;
	private String state;
	private boolean addressBool = false;

	/**
	 * Initializes the applet Ics314ui
	 */
	@Override
	public void init() {
		/* Set the Nimbus look and feel */
		// <editor-fold defaultstate="collapsed"
		// desc=" Look and feel setting code (optional) ">
		/*
		 * If Nimbus (introduced in Java SE 6) is not available, stay with the
		 * default look and feel. For details see
		 * http://download.oracle.com/javase
		 * /tutorial/uiswing/lookandfeel/plaf.html
		 */
		this.setSize(1050, 600); // Matt Kanda added 10/25/2013
		try {
			for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager
					.getInstalledLookAndFeels()) {
				if ("Nimbus".equals(info.getName())) {
					javax.swing.UIManager.setLookAndFeel(info.getClassName());
					break;
				}
			}
		} catch (ClassNotFoundException ex) {
			java.util.logging.Logger.getLogger(ics314ui.class.getName()).log(
					java.util.logging.Level.SEVERE, null, ex);
		} catch (InstantiationException ex) {
			java.util.logging.Logger.getLogger(ics314ui.class.getName()).log(
					java.util.logging.Level.SEVERE, null, ex);
		} catch (IllegalAccessException ex) {
			java.util.logging.Logger.getLogger(ics314ui.class.getName()).log(
					java.util.logging.Level.SEVERE, null, ex);
		} catch (javax.swing.UnsupportedLookAndFeelException ex) {
			java.util.logging.Logger.getLogger(ics314ui.class.getName()).log(
					java.util.logging.Level.SEVERE, null, ex);
		}
		// </editor-fold>

		/* Create and display the applet */
		try {
			java.awt.EventQueue.invokeAndWait(new Runnable() {
				public void run() {
					initComponents();
					clear();
					printButton.setEnabled(false);
					jButton1.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							// call calculate to do calculation
							validate();
						}
					});

					// Clears and sets field to blank.
					clearButton.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							clear();
						}
					});

					printButton.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							// call calculate to do calculation
							print();
						}
					});

					latlong.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							address = addressField.getText();
							city = cityField.getText();
							state = stateField.getText();
							if (city.length() > 0 && address.length() > 0
									&& state.length() > 0) {
								CityState cs = new CityState(address, city,
										state);
								jTextArea1.append("\nYour city latitude is: "
										+ cs.getLat());
								jTextArea1.append("\nYour city longitude is: "
										+ cs.getLong());
								jLatitudeField.setText("" + cs.getLat());
								jLongitudeField.setText("" + cs.getLong());
							}
						}
					});
                                        
                                        
                                        helpButton.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
                                                HelpWindow help = new HelpWindow();
                                                }
                                        });
				}
			});
		} catch (Exception ex) {
			// ex.printStackTrace();
		}
	}

	/**
	 * Having a main enables the resize of the applet with netbeans. Unsure if
	 * there is another workaround.
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		new ics314ui().start();
	}

	/**
	 * This method is called from within the init() method to initialize the
	 * form. WARNING: Do NOT modify this code. The content of this method is
	 * always regenerated by the Form Editor.
	 */
	@SuppressWarnings("unchecked")
	// <editor-fold defaultstate="collapsed"
	// <editor-fold defaultstate="collapsed"
	// <editor-fold defaultstate="collapsed"
	// <editor-fold defaultstate="collapsed"
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jPanel2 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        printButton = new javax.swing.JButton();
        clearButton = new javax.swing.JButton();
        jLatitudeField = new javax.swing.JTextField();
        jLongitudeField = new javax.swing.JTextField();
        jDateField = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        addressField = new javax.swing.JTextField();
        cityField = new javax.swing.JTextField();
        stateField = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        latlong = new javax.swing.JButton();
        helpButton = new javax.swing.JButton();

        setBackground(new java.awt.Color(204, 204, 204));

        jScrollPane1.setBackground(java.awt.Color.lightGray);
        jScrollPane1.setBorder(null);

        jTextArea1.setColumns(20);
        jTextArea1.setLineWrap(true);
        jTextArea1.setRows(5);
        jTextArea1.setText("Enter address/city/state then press calc lat/long from address or enter latitude, longitude and date then press create gnomon.\nTo print gnomon press print button.\nFor more help, press the help button.\nTo clear fields, press clear all.");
        jTextArea1.setWrapStyleWord(true);
        jScrollPane1.setViewportView(jTextArea1);

        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 0, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 0, Short.MAX_VALUE)
        );

        jButton1.setText("Create Gnomon");
        jButton1.setMaximumSize(new java.awt.Dimension(150, 30));
        jButton1.setMinimumSize(new java.awt.Dimension(150, 30));
        jButton1.setPreferredSize(new java.awt.Dimension(100, 30));
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        printButton.setText("Print");
        printButton.setMaximumSize(new java.awt.Dimension(150, 30));
        printButton.setMinimumSize(new java.awt.Dimension(150, 30));
        printButton.setPreferredSize(new java.awt.Dimension(100, 30));

        clearButton.setText("Clear All");
        clearButton.setMaximumSize(new java.awt.Dimension(150, 30));
        clearButton.setMinimumSize(new java.awt.Dimension(150, 30));
        clearButton.setPreferredSize(new java.awt.Dimension(100, 30));

        jLatitudeField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jLatitudeFieldActionPerformed(evt);
            }
        });

        jLongitudeField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jLongitudeFieldActionPerformed(evt);
            }
        });

        jLabel1.setText("Latitude");

        jLabel2.setText("Longitude");

        jLabel3.setText("Date");

        addressField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addressFieldActionPerformed(evt);
            }
        });

        cityField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cityFieldActionPerformed(evt);
            }
        });

        stateField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                stateFieldActionPerformed(evt);
            }
        });

        jLabel4.setText("Address");

        jLabel5.setText("City");

        jLabel6.setText("State");

        latlong.setText("Calc lat/long from address");
        latlong.setMaximumSize(new java.awt.Dimension(150, 30));
        latlong.setMinimumSize(new java.awt.Dimension(150, 30));
        latlong.setPreferredSize(new java.awt.Dimension(100, 30));
        latlong.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                latlongActionPerformed(evt);
            }
        });

        helpButton.setText("Help");

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(layout.createSequentialGroup()
                            .add(18, 18, 18)
                            .add(jLabel1))
                        .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                            .add(10, 10, 10)
                            .add(jLabel3)))
                    .add(layout.createSequentialGroup()
                        .addContainerGap()
                        .add(jLabel2)))
                .add(10, 10, 10)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLatitudeField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 249, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLongitudeField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 249, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jDateField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 249, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(jButton1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE)
                    .add(printButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE)
                    .add(helpButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .add(10, 10, 10)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jLabel4)
                    .add(jLabel6)
                    .add(jLabel5))
                .add(4, 4, 4)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(addressField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 206, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(cityField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 206, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(stateField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 206, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(clearButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(latlong, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .add(274, 274, 274))
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(layout.createSequentialGroup()
                        .add(20, 20, 20)
                        .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 1144, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .add(81, 81, 81))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(15, 15, 15)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(layout.createSequentialGroup()
                                .add(5, 5, 5)
                                .add(jLabel1))
                            .add(layout.createSequentialGroup()
                                .add(2, 2, 2)
                                .add(jLatitudeField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(12, 12, 12)
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                    .add(jLongitudeField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(jLabel2))
                                .add(12, 12, 12)
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                    .add(jDateField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(jLabel3)))
                            .add(layout.createSequentialGroup()
                                .add(1, 1, 1)
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                    .add(addressField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(jLabel4))
                                .add(12, 12, 12)
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                    .add(cityField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(jLabel5))
                                .add(8, 8, 8)
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                    .add(stateField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(jLabel6)
                                    .add(clearButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))))
                    .add(layout.createSequentialGroup()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(layout.createSequentialGroup()
                                .add(15, 15, 15)
                                .add(jButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(6, 6, 6)
                                .add(printButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                            .add(layout.createSequentialGroup()
                                .add(16, 16, 16)
                                .add(latlong, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 52, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(helpButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 30, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .add(29, 29, 29)
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 335, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(154, 154, 154))
        );
    }// </editor-fold>//GEN-END:initComponents

	private void addressFieldActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_addressFieldActionPerformed
		// TODO add your handling code here:
	}// GEN-LAST:event_addressFieldActionPerformed

	private void cityFieldActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_cityFieldActionPerformed
		// TODO add your handling code here:
	}// GEN-LAST:event_cityFieldActionPerformed

	private void stateFieldActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_stateFieldActionPerformed
		// TODO add your handling code here:
	}// GEN-LAST:event_stateFieldActionPerformed

	private void latlongActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_latlongActionPerformed
		// TODO add your handling code here:
	}// GEN-LAST:event_latlongActionPerformed

	private void jLongitudeFieldActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jLongitudeFieldActionPerformed
		// TODO add your handling code here:
	}// GEN-LAST:event_jLongitudeFieldActionPerformed

	private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButton1ActionPerformed
		// TODO add your handling code here:
	}// GEN-LAST:event_jButton1ActionPerformed

	private void jLatitudeFieldActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jLatitudeFieldActionPerformed
		// TODO add your handling code here:
	}// GEN-LAST:event_jLatitudeFieldActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField addressField;
    private javax.swing.JTextField cityField;
    private javax.swing.JButton clearButton;
    private javax.swing.JButton helpButton;
    private javax.swing.JButton jButton1;
    private javax.swing.JTextField jDateField;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JTextField jLatitudeField;
    private javax.swing.JTextField jLongitudeField;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JButton latlong;
    private javax.swing.JButton printButton;
    private javax.swing.JTextField stateField;
    // End of variables declaration//GEN-END:variables
	/**
	 * Creates the gnomon and face with the sundial math class, then sending
	 * results to drawface and draw gnomon
	 * 
	 * @param latitude
	 * @param longitude
	 * @param date
	 */
	public void calculate(double latitude, double longitude, String date) {
		// create a SundialMath
		SundialMath test = new SundialMath();
		test.setInputs(latitude, longitude, date); // send the data to
		// SundialMath
		double[] HL = test.getHourLines(); // upload the hour line's degree to
		// HL
		// jTextArea1.append("Type string here"); //This is how to output stuff
		// to the window
		drawG = new DrawGnomon(test.getGnomon());
		drawF = new DrawFace(HL, Double.parseDouble(jLatitudeField.getText()),
				drawG.getLength());
	}

	/**
	 * Input validation for latitude and longitude
	 */
	public boolean fieldValidation() {
		boolean valid = true;
		if (jLatitudeField.getText().length() == 0
				|| jLongitudeField.getText().length() == 0
				|| jDateField.getText().length() == 0) {
			return false;
		}
		try {
			double a = Double.parseDouble(jLatitudeField.getText());
			if (a > 90 || a < -90) {
				jTextArea1
						.append("\nNumbers must be between -90 to 90 in the latitude Field\n");
				return false;
			}
		} catch (Exception e) {
			jTextArea1
					.append("\nPlease enter a number in the latitude Field\n");
			return false;
		}
		try {
			double b = Double.parseDouble(jLongitudeField.getText());
			if (b > 180 || b < -180) {
				jTextArea1
						.append("\nPlease enter a number in the longitude field\n");
				return false;
			}
		} catch (Exception e) {
			jTextArea1
					.append("\nPlease enter a number between -180 to 180 in the longitude field\n");
			return false;
		}
		return valid;
	}

	/**
	 * Checks if input is valid. If true, sets lat and lon.
	 */
	public void validate() {
		if (fieldValidation()) {
			lat = Double.parseDouble(jLatitudeField.getText());
			lon = Double.parseDouble(jLongitudeField.getText());
			calculate(lat, lon, jDateField.getText());
			printButton.setEnabled(true);
		}
	}

	public void testValidate() {
		if (fieldValidation()) {
			lat = Double.parseDouble(jLatitudeField.getText());
			lon = Double.parseDouble(jLongitudeField.getText());
			printButton.setEnabled(true);
		}
	}

	/**
	 * @return latitude, primarily for test cases
	 */
	public double getLatitude() {
		return this.lat;
	}

	/**
	 * @return longitude, primarily for test cases
	 */
	public double getLongitude() {
		return this.lon;
	}

	/**
	 * Used for test purposes. Sets values.
	 */
	public void setTestValues(double tempLat, double tempLong, String tempDate) {
		jLatitudeField.setText("" + tempLat);
		jLongitudeField.setText("" + tempLong);
		jDateField.setText(tempDate);
	}

	/**
	 * Prints the results of drawFace and drawGnomon
	 */
	public void print() {
		PrinterJob job = PrinterJob.getPrinterJob();
		PageFormat pf = job.defaultPage();
		pf.setOrientation(PageFormat.LANDSCAPE);
		job.setPrintable(drawF, pf);

		boolean ok = job.printDialog();
		if (ok) {
			try {
				job.print();
			} catch (PrinterException ex) {
				/* The job did not successfully complete */
			}
		}
		job.setPrintable(drawG, pf);
		ok = job.printDialog();
		if (ok) {
			try {
				job.print();
			} catch (PrinterException ex) {
				/* The job did not successfully complete */
			}
		}
	}

	/**
	 * Clears fields and any data that has been input.
	 */
	public void clear() {
		lat = 0;
		lon = 0;
		drawF = null;
		drawG = null;
		jLatitudeField.setText("");
		jLongitudeField.setText("");
		jDateField.setText("");
		addressField.setText("");
		cityField.setText("");
		stateField.setText("");
		jTextArea1
				.setText("Instructions:\n"
						+ "Enter your address, city and state then press the calculate lat/long from address button."
						+ "Valid values for latitude are between -90 and 90.\n"
						+ "Valid values for longitude are between -180 and 180.\n"
						+ "For the date please enter in this format YYYY/MM/DD;\n"
						+ "\n"
						+ "To use:\n"
						+ "Cut the entire piece marked A out, making sure to not cut any black lines.\n"
						+ "A correct piece should be a triangle with an attached rectangle.\n"
						+ "Fold along the line between the rectangle and triangle, then place fold on the line that makes a 90 degree angle with the base.\n"
						+ "Point the 12 towards north if above the equator (if your latitude is positive) and point the 12 south below the equator (if your latitude is negative).\n"
						+ "The small end of the gnomon must face the base."
						+ "The location of the shadow is the current time.");
		printButton.setEnabled(false);
	}
}
